package com.android.equipment.adapter

import android.graphics.Color
import com.android.equipment.R
import com.android.equipment.bean.WorkDetailDeviceData
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class SelectDeviceAdapter(layoutRes: Int): BaseQuickAdapter<WorkDetailDeviceData, BaseViewHolder>(layoutRes) {
    override fun convert(holder: BaseViewHolder, item: WorkDetailDeviceData) {
        holder.setText(R.id.tv_device_name, item.deviceName)
        holder.setText(R.id.tv_device_code, item.deviceCode)
        if (item.isExit){
            holder.itemView.isEnabled = false
            holder.itemView.setBackgroundResource(R.drawable.shape_radius_5_solid_f2f2f2)
            holder.setTextColor(R.id.tv_device_name, Color.parseColor("#999999"))
            holder.setTextColor(R.id.tv_device_code, Color.parseColor("#999999"))
        }else{
            holder.itemView.isEnabled = true
            holder.itemView.setBackgroundResource(R.drawable.shape_radius_5_solid_white_stroke_1_f2f2f2)
            holder.setTextColor(R.id.tv_device_name, Color.parseColor("#333333"))
            holder.setTextColor(R.id.tv_device_code, Color.parseColor("#333333"))
        }
    }
}